﻿using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using Think9.Models;
using Think9.Services.Base;
using Think9.Services.Table;

namespace Think9.Controllers.Basic
{
    [Area("SysTable")]
    public class TableListController : BaseController
    {
        private TbBasicService TbBasicService = new TbBasicService();
        private ComService ComService = new ComService();
        private string dbtype = DBType.mysql.ToString();//数据库类型

        public override ActionResult Index(int? id)
        {
            base.Index(id);

            return View();
        }

        [HttpPost]
        public ActionResult GetTableTreeSelect()
        {
            List<TreeGridEntity> list = TbBasicService.GetTableTreeSelect();

            var menuJson = Newtonsoft.Json.JsonConvert.SerializeObject(list);

            var result = SuccessTip("操作成功", menuJson);

            return Json(result);
        }

        [HttpGet]
        public JsonResult GetTbList(TbBasicEntity model, PageInfoEntity pageInfo, string key)
        {
            string _keywords = key == null ? "" : key;
            pageInfo.field = "OrderNo";
            string where = "where TbType='1'";
            if (_keywords != "")
            {
                where += " and (TbId like @TbName OR TbName like @TbName) ";
                model.TbName = string.Format("%{0}%", _keywords);
            }
            var result = TbBasicService.GetPageByFilter(model, pageInfo, where);
            return Json(result);
        }
    }
}